package TestTime;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * Created with IntelliJ IDEA.
 * User: leep
 * Date: 16-2-4
 * Time: 下午5:08
 * To change this template use File | Settings | File Templates.
 */
public class TimerTest02 {
	Timer timer;

	public TimerTest02() {
		Date time = getTime();
		System.out.println("指定时间time=" + time);
		timer = new Timer();
		timer.schedule(new TimerTaskTest02(), time);
	}

	public Date getTime() {
		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.HOUR_OF_DAY, 14);
		calendar.set(Calendar.MINUTE, 30);
		calendar.set(Calendar.SECOND, 00);
		Date time = calendar.getTime();

		return time;
	}

	public static void main(String[] args) {
		new TimerTest02();
	}
}

class TimerTaskTest02 extends TimerTask {

	@Override
	public void run() {
		System.out.println("指定时间执行线程任务...");
		System.gc();
	}
}
